import request from '@/config/axios'

// 字典类型 VO
export interface BizDictTypeVO {
  id: number // 字典ID
  label: string // 字典标签
}

// 字典类型 API
export const BizDictTypeApi = {
  // 查询字典类型分页
  getBizDictTypePage: async (params: any) => {
    return await request.get({ url: `/business/biz-dict-type/page`, params })
  },

  // 查询字典类型详情
  getBizDictDataByTypeId: async (id: number) => {
    return await request.get({ url: `/business/biz-dict-type/data/` + id })
  },


  // 查询字典类型详情
  getBizDictDataByTypeIdProject: async () => {
    return await request.get({ url: `/business/biz-dict-type/get/project` })
  },

  // 查询字典类型详情
  getBizDictType: async (id: number) => {
    return await request.get({ url: `/business/biz-dict-type/get?id=` + id })
  },

  // 新增字典类型
  createBizDictType: async (data: BizDictTypeVO) => {
    return await request.post({ url: `/business/biz-dict-type/create`, data })
  },

  // 修改字典类型
  updateBizDictType: async (data: BizDictTypeVO) => {
    return await request.put({ url: `/business/biz-dict-type/update`, data })
  },

  // 删除字典类型
  deleteBizDictType: async (id: number) => {
    return await request.delete({ url: `/business/biz-dict-type/delete?id=` + id })
  },

  // 导出字典类型 Excel
  exportBizDictType: async (params) => {
    return await request.download({ url: `/business/biz-dict-type/export-excel`, params })
  },

// ==================== 子表（字典数据） ====================

  // 获得字典数据分页
  getBizDictDataPage: async (params) => {
    return await request.get({ url: `/business/biz-dict-type/biz-dict-data/page`, params })
  },
  // 新增字典数据
  createBizDictData: async (data) => {
    return await request.post({ url: `/business/biz-dict-type/biz-dict-data/create`, data })
  },

  // 修改字典数据
  updateBizDictData: async (data) => {
    return await request.put({ url: `/business/biz-dict-type/biz-dict-data/update`, data })
  },

  // 删除字典数据
  deleteBizDictData: async (id: number) => {
    return await request.delete({ url: `/business/biz-dict-type/biz-dict-data/delete?id=` + id })
  },

  // 获得字典数据
  getBizDictData: async (id: number) => {
    return await request.get({ url: `/business/biz-dict-type/biz-dict-data/get?id=` + id })
  },
}
